/*!
 * @Author:ResetDay
 * @GitHub:https://github.com/ResetDay
 * @Email:ResetZeroDay@gmail.com
 * @Blog:https://blog.ResetDay.top
 * @Copyright http://echarts.baidu.com/
 */

//画板
var dom = document.getElementById("container");
//时间显示文本
var date_text = document.getElementById("date_text");

//初始化（默认Canvas渲染）
var myChart = echarts.init(dom);


//设置初始化数据
myChart.setOption(option_init, true);



//读取服务器数据
/* function ajaxPush() {
    $.ajax({
        url: "http://localhost:8088/readRank",
        type: 'GET',
        async: false,
        dataType: "json",
        success: function(result) {
            var code=result['status'];
            var obj;
            if(code==0){
                obj = eval(result['data'])
            }
            console.log(obj);

            pushOption(obj);

        },
        error: function() {
            alert("失败!");
        }
    },1000);

};  
*/

function pushOption(obj){

    //修改榜首名字
    topUP=obj[0].uname;
    console.log(topUP);
    //修改背景
    var bg_img = new Image();
    bg_img.src=obj[0].pic;
    //显示时间
    date_text.innerHTML=obj[0].date;

    myChart.hideLoading();
    myChart.setOption({
        title: {
            backgroundColor: {
                    image: bg_img,
                    repeat: 'repeat'
                    }        
            },
        dataset: {
            source:
                obj
        },
        series: [{
            name: topUP,
            itemStyle: {
                normal: {
                   color: {
                       image: bg_img, 
                    }
                 }
               },
               markPoint: {
                   label: {
                      normal: {
                           backgroundColor: {
                               image:bg_img,
                               }
                      }
                      }
               }
        }]
    });  
}

